<template>
  <div class="mod-sys__user">
      <el-form :inline="true" :model="state.dataForm" @keyup.enter="state.getDataList()">
          <el-form-item label="课程名称">
            <el-input v-model="state.dataForm.username" placeholder="课程名称" clearable></el-input>
        </el-form-item>
          <el-form-item label="签到类型">
            <el-input v-model="state.dataForm.username" placeholder="签到类型" clearable></el-input>
        </el-form-item>
          <el-form-item>
              <el-button @click="state.getDataList()">查询</el-button>
          </el-form-item>
      </el-form>
      <TableWrapper :valueData="groupList" :columns="columns" :optrations="optrations" @pageSize="pageSize"
          @currentPage="currentPage" :pageCurrent="{...pageCurrent,total}">
      </TableWrapper>
  </div>
</template>

<script lang="ts" setup>
  import useView from "@/hooks/useView";
  import { reactive, ref, toRefs, onMounted } from "vue";
  import TableWrapper from "@/components/table/TableWrapper.vue";
  import AddOrUpdate from "./user-add-or-update.vue";

  const view = reactive({
      getDataListIsPage: true,
  });
  const total = ref('0')
  const pageCurrent = reactive({
      pageNum: '1',
      pageSize: 20
  })
  const columns = ref([
      {
          value: 'parentName',
          label: '课程名称'
      },
      {
          value: 'parentName',
          label: '授课老师'
      },
      {
          value: 'parentName',
          label: '签到类型'
      },
      {
          value: 'parentName',
          label: '签到截止时间'
      },
      {
          value: 'parentName',
          label: '签到时间'
      },
  ])
  const optrations = [
    {
      name: '编辑',
      type: 'primary',
      icon: 'el-icon-plus',
      method: (columns, row) => {
        type.value = 'edit'
        modelValue.value = row
        gropdialogVisible.value = true
      },
      disabled: false
    },
    {
      name: '删除',
      type: 'danger',
      icon: 'el-icon-plus',
      method: (columns, row) => {
        ElMessageBox.confirm("确定进行[删除]操作?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
          .then(() => {
            baseService
              .delete("/lca/equipment/category/delete", {
                id: row.id
              })
              .then((res) => {
                ElMessage.success({
                  message: "成功",
                  duration: 500,
                });
                getClassList()
                getGroupList()
              })
          })
          .catch(() => {
            //
          });
      },
      disabled: false
    }
  ]
  onMounted(() => {
      // getList()
  });
  const getDataList=() => {
      // getList()
  }
  const getList = () => {
      let param = {
          ...pageCurrent,
          query: {
              parentId: id || classListId.value,
              name: name
          }
      };
      baseService
          .post("/lca/equipment/category/pageList", param)
          .then((res) => {
              if (res.code === 0) {
                  pageList.value = res.data.records
                  total.value = res.data.total
              } else {
                  ElMessage.error(res.msg);
              }
          })
          .catch(() => {
          });

  }

  const pageSize = (val) => {
      pageCurrent.pageSize = val
      getList()
  }
  const currentPage = (val) => {
      pageCurrent.pageNum = val
      getList()
  }
  const state = reactive({ ...useView(view), ...toRefs(view) });
</script>